<template>
  <div class="mine-order bs">
    <div class="mine-order-title">
      <text class="mine-order-title-text">代理体系</text>
    </div>
    <div class="mine-order-info">
      <div class="mine-order-unpaid" @click="storeOccupancyClick" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>
        <text class="mine-order-name">便士达站点</text>
      </div>
      <div class="mine-order-unpaid" @click="goToProduct(16)" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>
        <text class="mine-order-name">区县代理</text>
      </div>
      <div class="mine-order-unpaid" @click="goToProduct(17)" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>
        <text class="mine-order-name">市级代理</text>
      </div>

      <!--      <div class="mine-order-unpaid" @click="shareClick" data-index="unpaid">-->
      <!--        <text class="mine-order-icon">&#xe6a3;</text>-->
      <!--        <text class="mine-order-name">邀请有礼</text>-->
      <!--      </div>-->
      <!--      <div class="mine-order-unpaid" @click="toAddress" data-index="unpaid">-->
      <!--        <text class="mine-order-icon">&#xe67a;</text>-->
      <!--        <text class="mine-order-name">收货地址</text>-->
      <!--      </div>-->
      <!--      <div class="mine-order-unpaid" @click="shoppingClick" data-index="unpaid">-->
      <!--        &lt;!&ndash; <text class="mine-order-icon" style="font-weight: bold">&#xe66d;</text> &ndash;&gt;-->
      <!--        <icon class="mine-order-icon" ref="reflectName" style="width:65px;height:65px;color:#000000;font-size:60px" content="tb-cart"></icon>-->
      <!--        <text class="mine-order-num totalColor" v-if="quantity > 0">{{quantity}}</text>-->
      <!--        <text class="mine-order-name">购物车</text>-->
      <!--      </div>-->
      <!--      <div class="mine-order-unpaid" @click="messageClick" data-index="unpaid">-->
      <!--        <text class=" mine-order-icon">&#xe660;</text>-->
      <!--        <text class="mine-order-num totalColor" v-if="unReadNum > 0">{{showUnReadNum}}</text>-->
      <!--        <text class="mine-order-name">消息通知</text>-->
      <!--      </div>-->
      <div class="mine-order-unpaid" @click="groupClick" data-index="unpaid">
        <text class="mine-order-icon">&#xe6aa;</text>
        <text class="mine-order-name">拉新订单</text>
      </div>
      <div class="mine-order-unpaid" @click="groupManagerClick" data-index="unpaid">
        <text class="mine-order-icon">&#xe6aa;</text>
        <text class="mine-order-name">团队订单</text>
      </div>
      <div class="mine-order-unpaid" @click="transferSystemClick" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>
        <text class="mine-order-name">线上商户</text>
      </div>
      <div class="mine-order-unpaid" @click="goToProduct(18)" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>
        <text class="mine-order-name">省级代理</text>
      </div>



      <!--      <div class="mine-order-unpaid" @click="TotransferFiltering" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe67d;</text>-->
      <!--        <text class="mine-order-name">权益转让</text>-->
      <!--      </div>-->
      <!--      <div class="mine-order-unpaid" @click="rewardRecordClick" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe67d;</text>-->
      <!--        <text class="mine-order-name">转让订单</text>-->
      <!--      </div>-->
      <div class="mine-order-unpaid" @click="merchantOrderClick" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe67e;</text>
        <text class="mine-order-name">商户收益</text>
      </div>





      <div class="mine-order-unpaid" @click="subRegistrationClick" data-index="unpaid">
        <text class=" mine-order-icon">&#xe671;</text>
        <text class="mine-order-name">子账号管理</text>
      </div>

      <div class="mine-order-unpaid" @click="safetyClick" data-index="unpaid">
        <text class=" mine-order-icon" style="font-weight: bold">&#xe696;</text>
        <text class="mine-order-name">账户安全</text>
      </div>
      <div class="mine-order-unpaid" @click="collectionMethodClick" data-index="unpaid">
        <text class="mine-order-icon" style="font-weight: bold">&#xe67c;</text>
        <text class="mine-order-name">收款方式</text>
      </div>
      <!--      <div class="mine-order-unpaid" @click="toExchangeDetails" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">兑换明细</text>-->
      <!--      </div>-->
      <!--      <div class="mine-order-unpaid" @click="toSharedProfitDetails" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">共享分润明细</text>-->
      <!--      </div>-->

      <!--<div class="mine-order-unpaid" @click="toShareProfit" data-index="unpaid">-->
      <!--<text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--<text class="mine-order-name">共享分润兑换</text>-->
      <!--</div>-->
      <!--<div class="mine-order-unpaid" @click="toSignContract" data-index="unpaid">-->
      <!--<text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--<text class="mine-order-name">签约</text>-->
      <!--</div>-->

      <!--      <div class="mine-order-unpaid" @click="toNearbyShopsClassification" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">店铺分类页</text>-->
      <!--      </div>-->




      <!--      <div class="mine-order-unpaid" @click="toTimeKill" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">限时秒杀</text>-->
      <!--      </div>-->

      <!--      <div class="mine-order-unpaid" @click="toSignIn" data-index="unpaid">-->
      <!--        <text class="mine-order-icon">&#xe66c;</text>-->
      <!--        <text class="mine-order-name">每日签到</text>-->
      <!--      </div>-->

      <!--      <div class="mine-order-unpaid" @click="toTimeKill" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">限时秒杀</text>-->
      <!--      </div>-->
      <!--      <div class="mine-order-unpaid" @click="toMerchantDetails" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">商家详情</text>-->
      <!--      </div>-->


      <!--      <div class="mine-order-unpaid" @click="transferSystemClick2" data-index="unpaid">-->
      <!--        <text class="mine-order-icon" style="font-weight: bold">&#xe6b2;</text>-->
      <!--        <text class="mine-order-name">转让系统2</text>-->
      <!--      </div>-->
    </div>
  </div>
</template>
<script>
import {count} from "@/api/cart";
import {list} from "@/api/wxPage";
import {queryShopStatus} from "@/api/order";
const eeui = app.requireModule('eeui');
import {
  unReadCount,
} from '@/api/msgPush'
export default {
  data() {
    return {
      shipped: 0,
      unshipping: 0,
      completed: 0,
      unpaid: 0,
      refunds: 0,
      showShipped: 0,
      showUnshipping: 0,
      showCompleted: 0,
      showUnpaid: 0,
      showRefunds: 0,
      unReadNum:"", //未读消息数
      showUnReadNum: "", //显示的未读数量
      quantity:'',
      queryShopStatus: 0,
      transferSystemId:'',
      transferFilterId:''
    }
  },
  props:[
    'time'
  ],
  created(){
    this.initIconFont()
    this.loadWxpage()
  },
  pageResume() {
    this.getQueryShopStatus()
    this.getunReadCount()
    this.getCartCount()
  },
  mounted() {
    this.getQueryShopStatus()
  },
  methods: {
    toShareProfit(){
      eeui.openPage({
            url: 'root://pages/member/shareProfit/shareProfit.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }
      );
    },
    toNearbyShopsClassification(){
      eeui.openPage({
            url: 'root://pages/member/nearbyShopsDetails/nearbyShopsClassification.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }
      );
    },

    toSignContract(){
      eeui.openPage({
            url: 'root://pages/member/signContract/signContract.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }
      );
    },
    toSharedProfitDetails(){
      eeui.openPage({
            url: 'root://pages/member/shareProfit/sharedProfitDetails.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }
      );
    },
    toExchangeDetails() {
      eeui.openPage({
            url: 'root://pages/member/shareProfit/exchangeDetails.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }
      );
    },

    goToProduct(data) {
      if (this.getGlobalData().token == null) {
        this.toPersonInfo()
        return;
      }
      const eeui = app.requireModule('eeui');
      eeui.openPage({
            params: data,
            url: 'root://pages/goods/product/details.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          },
          (result) => {
          }
      );
    },
    getQueryShopStatus(){
      queryShopStatus().then(res=>{
        this.queryShopStatus = res.data.status
        // this.queryShopStatus = 1
      })
    },
    safetyClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
            url: 'root://pages/member/accountSecurity/safety',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {}
      );
    },
    subRegistrationClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
            url: 'root://pages/member/subRegistration/index',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {}
      );
    },
    shoppingClick(){
      eeui.openPage({
            url: 'root://pages/tabBar/shoppingCart',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {}
      );
    },
    getCartCount() {
      var _this = this
      let globalData = this.getGlobalData();
      if (globalData.token == null) {
        return
      }
      let data = {}
      data.uuid = globalData.uuid,
          count(data).then(
              res => {
                if (res.data.quantity > 0) {
                  this.quantity=res.data.quantity
                }
              }
          ).catch(error => {
          })
    },
    getunReadCount() {
      unReadCount().then(
          res => {
            // console.log("接收用户信息--" + JSON.stringify(res))
            if (res.type == 'success') {
              let unReadNum = 0
              if (res.data.length > 0) {
                res.data.map(item => {
                  unReadNum += item.msg_num
                })
              }
              this.unReadNum = unReadNum
              // console.log(this.unReadNum,"11111111111111111111")
              if(unReadNum > 100){
                this.showUnReadNum = "..."
              }else {
                this.showUnReadNum =  unReadNum
              }
            }
          }
      ).catch(error => {
      })
    },

    // 推广中心
    toShareCenter() {
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
            url: 'root://pages/member/share/share',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {}
      );

    },
    messageClick() {
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/message/index.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
      });
    },
    getTraceCount() {
      traceCount().then(
          res => {
            if (res.type == 'success') {
              this.footprint = res.data
            }
          }
      ).catch(error => {
        console.log(error)
      })
    },

    //收货地址
    toAddress: function (e) {
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/address/address.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
      });
    },

    //跳转到所有的订单页面
    toOrder: function(e) {
      this.checkLogin(() => {
        let param = e.currentTarget.dataset.index
        console.info(param)
        wx.navigateTo({
          url: '/pages/member/order/index?index=' + 0,
        })
      })
    },
    toOrderRefund: function() {
      this.checkLogin(() => {
        wx.navigateTo({
          url: '/pages/member/refund/list',
        })
      })

    },
    toSignIn: function(e) {
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/function/signIn.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
      });
    },
    toNotDelivered: function(e) {
      this.checkLogin(() => {
        wx.navigateTo({
          url: '/pages/member/order/index?index=' + 2,
        })
      })
    },
    toBeReceived: function(e) {
      this.checkLogin(() => {
        wx.navigateTo({
          url: '/pages/member/order/index?index=' + 3,
        })
      })
    },
    toEvaluate: function(e) {
      this.checkLogin(() => {
        wx.navigateTo({
          url: '/pages/member/order/index?index=' + 4,
        })
      })
    },
    //检测用户的登陆状态
    checkLogin(callback) {
      if (this.getGlobalData().token == null) {
        wx.navigateTo({
          url: '/pages/login/index',
        })
      } else {
        if (callback) {
          callback()
        }
      }
    },
    shareClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/share/index.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
        if (result.status == 'stop') {

        }
      });
    },
    groupClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/groupbuy/order.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
        if (result.status == 'stop') {

        }
      });
    },
    groupManagerClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/groupbuy/orderStatistics.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
        if (result.status == 'stop') {
        }
      });
    },
    storeOccupancyClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      if(this.queryShopStatus == 0){
        eeui.openPage({
              params: 15,
              url: 'root://pages/goods/product/details.js',
              statusBarType: 'immersion',
              statusBarStyle: false
            }, (result) => {
            }
        );
      } else if (this.queryShopStatus == 1) {
        eeui.openPage({
          url: "root://pages/member/storeOccupancy/storeOccupancy.js",
          params: { type: "add" },
          statusBarType: 'immersion',
          statusBarStyle: false
        }, result => {
          if (result.status == 'stop') {
          }
        });
        return false;
      }
    },
    loadWxpage() {
      list({
        mchId: this.getGlobalData().mchId,
        pageNum: 1,
        pageSize: 10,
        sortField: 'orders',
        direction: 'asc'
      }).then(res => {
        this.mchId = this.getGlobalData().mchId
        //10是抢拍过滤页
        res.data.data.forEach(item=>{
          if (item.orders ==  50){
            console.info(item.id)
            this.transferSystemId = item.id
          }
          if (item.orders ==  60){
            console.info("2222222222222222222222222222222222222222222")
            console.info(item.id)
            console.info("3333333333333333333333333")
            this.transferFilterId = item.id
          }

        })
      })
    },
    transferSystemClick(){
      // 50是站点服务
      eeui.openPage({
        url: 'root://pages/index/wxPage/wxPage.js',
        params: this.transferSystemId,
        statusBarType: 'immersion',
        statusBarStyle: false
      });
    },

    TotransferFiltering(){
      // 60是转让过滤页面
      eeui.openPage({
        url: 'root://pages/index/wxPage/wxPage.js',
        params: this.transferFilterId,
        statusBarType: 'immersion',
        statusBarStyle: false
      });
    },
    transferSystemClick2(){
      eeui.openPage({
            params: 15,
            url: 'root://pages/member/transferSystem/transferSystem2.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },
    collectionMethodClick(){
      eeui.openPage({
            url: 'root://pages/member/paymentMethod/collectionMethod.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },
    toTimeKill(){
      eeui.openPage({
            url: 'root://pages/index/component/timeKill/timeKill.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },
    toMerchantDetails(){
      eeui.openPage({
            url: 'root://pages/member/merchantDetails/merchantDetails.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },

    rewardRecordClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
            url: 'root://pages/member/transferSystem/rewardRecord.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },
    merchantOrderClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
            url: 'root://pages/member/transferSystem/merchantOrder.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },

    toTransferFiltering(){
      eeui.openPage({
            url: 'root://pages/index/component/transferActivities/transferFiltering.js',
            statusBarType: 'immersion',
            statusBarStyle: false
          }, (result) => {
          }
      );
    },

    realNameClick(){
      if (this.getGlobalData().token == null) {
        eeui.toast('请先登录')
        return;
      }
      eeui.openPage({
        url: 'root://pages/member/realName/index.js',
        statusBarType: 'immersion',
        statusBarStyle: false
      }, result => {
        if (result.status == 'stop') {

        }
      });
    }
  }
}
</script>

<style scoped>
.mine-order {
  margin-top: 20px;
  margin-left: 30px;
  margin-right: 30px;
  background-color: rgba(255, 255, 255, 1);
  border-radius: 16px;
}

.mine-order-title {
  font-size: 30px;
  position: relative;
  height: 80px;
  line-height: 80px;
  border-bottom-width: 1px;
  border-bottom-style: solid;
  border-bottom-color: rgba(231, 233, 237, 1);
  padding-left: 40px;
  padding-right: 30px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.mine-order-title-text {
  font-size: 30px;
}

.mine-order-title-more {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.mine-order-title-more_title {
  font-size: 25px;
  font-weight: 400;
  color: rgba(26, 26, 30, 1);
  opacity: 0.5;
}

.mine-order-arrow {
  font-family: iconfont2;
  width: 25px;
  height: 30px;
  font-size: 30px;
  color: #888888;
  margin-bottom: 2px;
}

.mine-order-title-more text {
  display: block;
}

.mine-order-info {
  display: flex;
  align-items: center;
  font-size: 25px;
  flex-direction: row;
  font-weight: 400;
  flex-wrap: wrap;
  padding-top: 30px;
}
.mine-order-info-image{
  width: 60px;
  height: 64px;
  margin-bottom: 15px
}

.mine-order-icon {
  margin-bottom: 10px;
  font-family: iconfont2;
  font-size: 60px;
  /*color: #DFBB85;*/
}

.mine-order-num {
  position: absolute;
  right: 50px;
  top: 1px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 30px;
  text-align: center;
  color: #fff;
}

.mine-order-unpaid {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  width: 172.5px;
  padding-bottom: 30px;
}

.mine-order-notdelivere {
  position: relative;
  text-align: center;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

.mine-order-delivered {
  position: relative;
  text-align: center;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.mine-order-evaluate {
  position: relative;
  text-align: center;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.mine-order-refund {
  position: relative;
  text-align: center;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.mine-order-bottomIcon {
  font-size: 24px;
  margin-top: 10px;
}
/* 小圆点 */
.totalColor{
  background-color: #fc5157
}

.mine-order-name{
  /*font-size: 22px;*/
  font-size: 26px;
  color: #333333;
}
</style>
